package site.nullable.recorder.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

private val LightColorScheme = lightColorScheme(
    primary = androidx.compose.ui.graphics.Color(0xFF006A6B),
    onPrimary = androidx.compose.ui.graphics.Color.White,
    background = androidx.compose.ui.graphics.Color.White,
    onBackground = androidx.compose.ui.graphics.Color.Black
)

private val DarkColorScheme = darkColorScheme(
    primary = androidx.compose.ui.graphics.Color(0xFF4CD8D9),
    onPrimary = androidx.compose.ui.graphics.Color.Black,
    background = androidx.compose.ui.graphics.Color(0xFF121212),
    onBackground = androidx.compose.ui.graphics.Color.White
)

// 红色系浅色主题
private val LightRedColorScheme = lightColorScheme(
    primary = Color(0xFFC62828),      // 深红色
    onPrimary = Color.White,          // 白色文字
    primaryContainer = Color(0xFFFFCDD2), // 浅红色容器
    onPrimaryContainer = Color(0xFF8E0000), // 深红色文字

    secondary = Color(0xFFD32F2F),    // 红色
    onSecondary = Color.White,
    secondaryContainer = Color(0xFFFFCDD2),
    onSecondaryContainer = Color(0xFF8E0000),

    tertiary = Color(0xFFB71C1C),     // 深红色
    onTertiary = Color.White,
    tertiaryContainer = Color(0xFFFFCDD2),
    onTertiaryContainer = Color(0xFF8E0000),

    background = Color(0xFFFFFBFF),   // 浅色背景
    onBackground = Color(0xFF201A1A), // 深灰色文字

    surface = Color(0xFFFFFBFF),      // 浅色表面
    onSurface = Color(0xFF201A1A),    // 深灰色文字

    surfaceVariant = Color(0xFFF5DDDB), // 浅红色变体表面
    onSurfaceVariant = Color(0xFF534342), // 深灰色文字

    error = Color(0xFFBA1A1A),        // 错误红色
    onError = Color.White,
    errorContainer = Color(0xFFFFDAD6),
    onErrorContainer = Color(0xFF410002),

    outline = Color(0xFF857372),      // 轮廓色
    outlineVariant = Color(0xFFD8C2C0),

    scrim = Color(0xFF000000),        // 遮罩色
)

// 红色系深色主题
private val DarkRedColorScheme = darkColorScheme(
    primary = Color(0xFFFFB4AB),      // 浅红色
    onPrimary = Color(0xFF690005),    // 深红色文字
    primaryContainer = Color(0xFF93000A), // 红色容器
    onPrimaryContainer = Color(0xFFFFDAD6), // 浅红色文字

    secondary = Color(0xFFFFB4AB),    // 浅红色
    onSecondary = Color(0xFF690005),
    secondaryContainer = Color(0xFF93000A),
    onSecondaryContainer = Color(0xFFFFDAD6),

    tertiary = Color(0xFFFFB4AB),     // 浅红色
    onTertiary = Color(0xFF680003),
    tertiaryContainer = Color(0xFF93000A),
    onTertiaryContainer = Color(0xFFFFDAD6),

    background = Color(0xFF201A1A),   // 深灰色背景
    onBackground = Color(0xFFEDE0DE), // 浅米色文字

    surface = Color(0xFF201A1A),      // 深灰色表面
    onSurface = Color(0xFFEDE0DE),    // 浅米色文字

    surfaceVariant = Color(0xFF534342), // 深红色变体表面
    onSurfaceVariant = Color(0xFFD8C2C0), // 浅米色文字

    error = Color(0xFFFFB4AB),        // 错误浅红色
    onError = Color(0xFF690005),
    errorContainer = Color(0xFF93000A),
    onErrorContainer = Color(0xFFFFDAD6),

    outline = Color(0xFFA08C8A),      // 轮廓色
    outlineVariant = Color(0xFF534342),

    scrim = Color(0xFF000000),        // 遮罩色
)

@Composable
fun RecorderTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val colorScheme = when {
        darkTheme -> DarkRedColorScheme
        else -> LightColorScheme
    }

    MaterialTheme(
        colorScheme = colorScheme,
        typography = androidx.compose.material3.Typography(),
        content = content
    )
}